home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Scan / 32-bit_x86 / Francais / cpsimage.cab / data / docio / checksum.elf next >
Text File  |  2009-03-16  |  1KB  |  48 lines

  1. // $Id: checksum.elf,v 1.3 2007/02/15 16:33:47 wayman Exp $
  2.  
  3. // Reads the checksums from the reference file and validates with actual image
  4. // use: xipe checksumChecker.elf -imp fn:s "checksumsFilename.txt";
  5. // Format of "checksumFilename.txt" is
  6. //        fullImagePathName imageSize imageChecksum
  7.  
  8. #import "documentio.ucm";
  9. #load "sys/stdio.elf";
  10. #load "docio/fileio.elf";
  11. LoadClasses(filename:"xeng");
  12.  
  13. // Returns TRUE if the checksum and size of the given file matches the 
  14. // given reference values.
  15.  
  16. PROCEDURE validateChecksum (STRING fn, LONG size, INTEGER checksum) 
  17.     RETURNS (BOOLEAN valid)
  18. {
  19.     valid = FALSE;
  20.     DOCUMENTREADER dr = CreateDocumentReader(filename:fn);
  21.     if (dr) 
  22.     {
  23.         INTEGER ichecksum = dr.getChecksum();
  24.  
  25.         FILE imageFile = new (FILE, path: fn);
  26.         LONG isize = imageFile.getSize();
  27.  
  28.         if ((size == isize) && (checksum == ichecksum))
  29.             valid = TRUE;
  30.     }
  31. }
  32.  
  33. // Returns the size and checksum of the image file given.
  34. PROCEDURE getChecksum (STRING fn) RETURNS (LONG size, INTEGER checksum)
  35. {
  36.     size = 0;
  37.     checksum = 0;
  38.  
  39.     DOCUMENTREADER dr = CreateDocumentReader(filename:fn);
  40.     if (dr)
  41.     {
  42.         checksum = dr.getChecksum();
  43.         FILE imageFile = new (FILE, path: fn);
  44.         size = imageFile.getSize();
  45.     }
  46. }
  47.  
  48.